Skip to content

Clarify hotspot scheduling isolation behavior - #22129

Open
doc-claw-bot wants to merge 6 commits into
pingcap:masterfrom
doc-claw-bot:docs-cn/hotspot-host-isolation-clarify
Open

doc-claw-bot wants to merge 6 commits into
pingcap:masterfrom
doc-claw-bot:docs-cn/hotspot-host-isolation-clarify

Conversation

@doc-claw-bot

@doc-claw-bot doc-claw-bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

What is changed, added, or deleted? (Required)

  • Clarify which hotspot scheduling paths honor replica placement constraints.
  • Clarify how to configure location-labels and isolation-level with Placement Rules enabled or disabled to preserve host-level isolation.
  • Add guidance that hot leader transfer does not repair an existing non-isolated replica layout by itself.

Which TiDB version(s) do your changes apply to? (Required)

Tips for choosing the affected version(s):

By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.

For details, see tips for choosing the affected versions (in Chinese).

  • master (the latest development version)
  • v9.0 (TiDB 9.0 versions)
  • v8.5 (TiDB 8.5 versions)
  • v8.1 (TiDB 8.1 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)

What is the related PR or file link(s)?

AI agent involvement

  • The changes in this PR were primarily made by an AI agent on behalf of the PR author.

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

Summary by CodeRabbit

  • 文档
    • 补充 Placement Rules 开启或关闭时,热点 Peer 迁移及读写热点 Leader 调度对标签约束和副本隔离的影响;说明 Leader 转移不会改变副本位置,热点迁移仍可能导致同一主机上出现多个副本。
    • 补充 host 级副本隔离所需的拓扑标签、默认规则与自定义规则配置,以及多规则场景下的副本约束说明。
    • 说明 host 级隔离不再优先跨 zone 或 rack 分散副本,并提示评估其对现有容灾要求和副本布局的影响。

@ti-chi-bot

ti-chi-bot Bot commented Dec 3, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign tangenta for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added contribution This PR is from a community contributor. missing-translation-status This PR does not have translation status info. labels Dec 3, 2026
@ti-chi-bot ti-chi-bot Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Dec 3, 2026
@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

文档补充 host 级副本隔离的配置条件,并说明 Placement Rules 和热点调度对副本位置及隔离约束的影响。

Changes: 副本隔离配置与热点调度

Layer / File(s) Summary
host 级副本隔离配置
configure-placement-rules.md、best-practices/pd-scheduling-best-practices.md
说明 Store 的 host 标签要求,以及默认规则和自定义规则的隔离配置方式。说明规则级隔离的适用范围和多规则下的主机约束。
热点调度的隔离限制
best-practices/pd-scheduling-best-practices.md、configure-placement-rules.md
说明 Placement Rules 开启或关闭时,热点调度对标签和隔离约束的处理差异。指出热点迁移可能使同一 Region 的多个副本位于同一主机。说明仅按 host 隔离时对 zone 和 rack 分布的影响。

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Other

Suggested reviewers: qiancai

Merge Risk: Low · previous review 310fc

The new host-isolation guidance is mostly accurate, but the hot-read-leader description does not yet distinguish master from v8.5. Readers of the master docs may get the wrong picture of how read hotspot migration treats location labels. Fix or confirm this before merge; the risk is low and affects documentation only.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题“Clarify hotspot scheduling isolation behavior”与变更内容相关。变更说明了哪些热点调度路径遵守副本放置约束,并说明 Placement Rules 开关状态下 location-labels 与 isolation-level 的配置方法,以保持 host 级别隔离。标题简洁,准确概括了主要变更。
Description check Passed 描述基本完整。已填写“变更内容”部分,列出三项修改:热点调度路径的约束行为、Placement Rules 开关下的 location-labels 与 isolation-level 配置方法、热点 Leader 转移不修复现有非隔离副本布局。版本选择已勾选 master 和 v8.5,AI 参与声明已勾选,关联链接已提供英文 PR。CLA 勾选项未勾选,且“Related code chang…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

描述基本完整。已填写“变更内容”部分,列出三项修改:热点调度路径的约束行为、Placement Rules 开关下的 location-labels 与 isolation-level 配置方法、热点 Leader 转移不修复现有非隔离副本布局。版本选择已勾选 master 和 v8.5,AI 参与声明已勾选,关联链接已提供英文 PR。CLA 勾选项未勾选,且“Related code change PR links”和“This PR is translated from”字段为空。这些属于次要项,不影响判定。

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 1ce2b35 and 310fce7.

Files selected for processing: 2

  • best-practices/pd-scheduling-best-practices.md
  • configure-placement-rules.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

@doc-claw-bot doc-claw-bot added ONCALL Relates to documentation oncall. type/bugfix This PR fixes a bug. area/scheduling Indicates that the Issue or PR belongs to the area of scheduling. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. labels Dec 3, 2026
@ti-chi-bot

ti-chi-bot Bot commented Dec 3, 2026

Copy link
Copy Markdown

In response to a cherrypick label: only pingcap org members may request cherry picks. If you are already part of the org, make sure to change your membership to public. Otherwise you can still do the cherry-pick manually.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments

Major 2
  1. 说明多条规则之间的隔离限制
  2. 说明 Peer 替换不一定保持硬隔离约束。
Minor 6
  1. 明确自定义 rule 中隔离字段的取值
  2. 说明同一主机上的 Store 必须使用相同的 host 标签值。
  3. 更正现有 Peer 的规则校验说明。
  4. 关闭 Placement Rules 时,需说明热点 Leader 迁移的隔离限制。
  5. 自定义 rule 需明确 host 隔离所需的字段值。
  6. 说明多条 Placement Rule 的隔离设置不约束跨规则副本。
Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 16cf933 and 92201af.

Files selected for processing: 2

  • best-practices/pd-scheduling-best-practices.md
  • configure-placement-rules.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

> - `move-hot-read-leader` 和 `move-hot-write-leader` 都属于以 Leader 为中心的调度路径。关闭 Placement Rules 时,`move-hot-read-leader` 在选择目标 Store 时不会校验 `location-labels` 或 `isolation-level`。开启 Placement Rules 时,这两条 Leader 路径仅会在目标 Store 还没有对应 Peer 时校验匹配到的 Placement Rule;如果只是把 Leader 转移给现有的 voter Peer,则不会借此提升或修复副本隔离度。
> - 如果你希望热点调度后仍满足 host 级别的副本隔离,需要先为每个 TiKV Store 配置 `host` 标签,然后按以下方式配置:
> - 关闭 Placement Rules 时,在 `replication.location-labels` 中包含 `host`,并将 `replication.isolation-level` 设置为 `host`;如果希望 PD 自动修复已不满足隔离要求的副本布局,请保持 `schedule.enable-location-replacement` 为开启状态。
> - 开启 Placement Rules 时,要么只保留默认 rule,并通过 `replication.location-labels` 和 `replication.isolation-level` 让 PD 生成 `location_labels` 包含 `host` 且 `isolation_level` 为 `host` 的默认 rule;要么在每条相关 Placement Rule 中显式设置 `location_labels` 和 `isolation_level`。不要指望仅靠热点 Leader 转移来修复已经不满足隔离要求的副本布局。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

自定义 rule 需明确 host 隔离所需的字段值。

第 94 行的自定义 rule 分支只要求“显式设置 location_labels 和 isolation_level”,没有给出取值。字段可以为空或设置为其他层级,此时规则不保证 host 隔离。请说明每条相关 Placement Rule 的 location_labels 应包含 host,且 isolation_level 应为 host。默认 rule 分支已写出这些值,可作为表述参照。

建议修改

->     - 开启 Placement Rules 时,要么只保留默认 rule,并通过 `replication.location-labels` 和 `replication.isolation-level` 让 PD 生成 `location_labels` 包含 `host` 且 `isolation_level` 为 `host` 的默认 rule;要么在每条相关 Placement Rule 中显式设置 `location_labels` 和 `isolation_level`。不要指望仅靠热点 Leader 转移来修复已经不满足隔离要求的副本布局。
+>     - 开启 Placement Rules 时,要么只保留默认 rule,并通过 `replication.location-labels` 和 `replication.isolation-level` 让 PD 生成 `location_labels` 包含 `host` 且 `isolation_level` 为 `host` 的默认 rule;要么在每条相关 Placement Rule 中显式设置 `location_labels` 包含 `host`,且 `isolation_level` 为 `host`。不要指望仅靠热点 Leader 转移来修复已经不满足隔离要求的副本布局。
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

Suggested change
> - 开启 Placement Rules 时,要么只保留默认 rule,并通过 `replication.location-labels` 和 `replication.isolation-level` 让 PD 生成 `location_labels` 包含 `host` 且 `isolation_level` 为 `host` 的默认 rule;要么在每条相关 Placement Rule 中显式设置 `location_labels` 和 `isolation_level`。不要指望仅靠热点 Leader 转移来修复已经不满足隔离要求的副本布局。
> - 开启 Placement Rules 时,要么只保留默认 rule,并通过 `replication.location-labels` 和 `replication.isolation-level` 让 PD 生成 `location_labels` 包含 `host` 且 `isolation_level` 为 `host` 的默认 rule;要么在每条相关 Placement Rule 中显式设置 `location_labels` 包含 `host`,且 `isolation_level` 为 `host`。不要指望仅靠热点 Leader 转移来修复已经不满足隔离要求的副本布局。

Minor · Functional Correctness · Quick win

说明多条 Placement Rule 的隔离设置不约束跨规则副本。

PD 按规则分别匹配 Peer,并按各规则自己的 Peer 计算隔离评分。pkg/schedule/placement/fit.go 中的 newRuleFit、compareBest 和 Replace 都只使用该规则内的 Peer 和 Store。因此,即使两条规则各包含一个 Peer 且都设置 isolation_level = host,这两个 Peer 仍可能位于同一 host 的不同 Store 上。

第 94 行在多条规则场景下会让用户认为整个 Region 的副本都已按 host 隔离。请补充说明:location_labels 和 isolation_level 只约束同一条规则内的 Peer,不保证不同规则的 Peer 位于不同 host。

Comment thread configure-placement-rules.md Resolved
@ti-chi-bot ti-chi-bot Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 3, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments

Minor 1
  1. 区分 master 与 v8.5 的读热点迁移行为
Additional comments: 1

configure-placement-rules.md-144-144: 1

144-144: Minor · Functional Correctness · Quick win

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

将非投票副本纳入跨规则隔离方案

如果 learner 由另一条规则管理,即使投票副本规则使用互不重叠的主机集合,learner 仍可能与投票副本同机。这不能满足本节“同一 Region 的副本”跨主机的目标。请说明该方案只保证投票副本之间的隔离;如需隔离所有副本,还需约束 learner 等其他副本规则。

As per coding guidelines,“涉及风险、限制、兼容性、数据丢失、性能影响时,必须明确说明影响范围和触发条件。”

Source: Coding guidelines

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 92201af and 1ce2b35.

Files selected for processing: 2

  • best-practices/pd-scheduling-best-practices.md
  • configure-placement-rules.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.


`move-hot-read-leader` 和 `move-hot-write-leader` 都会迁移 Leader 所在的副本。是否开启 Placement Rules 会影响迁移后的隔离结果:

- 关闭 Placement Rules:`move-hot-read-leader` 不检查 `location-labels` 或 `isolation-level`。`move-hot-write-leader` 会根据 `location-labels` 选择目标,但不直接检查 `isolation-level`。因此,仅设置 `isolation-level = "host"` 不能保证迁移后的 host 隔离。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

区分 master 与 v8.5 的读热点迁移行为

关闭 Placement Rules 且配置了 location-labels 时,PD master 已对迁移到无副本 Store 的读热点 Leader 目标执行位置检查(tikv/pd#11353,2026 年 11 月 2 日合入 master)。因此,第 94 行“move-hot-read-leader 不检查 location-labels”的描述不适用于 master。该修复只涉及 location-labels 的位置检查,未涉及 isolation-level,该段关于 isolation-level 的描述需要保留。同一段中关于同机副本的限制说明也需要按 master 行为重新核对。

请为 master 和 v8.5 分别写明读热点迁移的行为。在 v8.5 文档中写明修复状态前,先确认该修复从哪个 v8.5.x 版本开始可用。

As per coding guidelines,“涉及版本变化时,必须说明从哪个版本开始生效或在哪些版本中支持。”

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/scheduling Indicates that the Issue or PR belongs to the area of scheduling. contribution This PR is from a community contributor. missing-translation-status This PR does not have translation status info. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. ONCALL Relates to documentation oncall. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/bugfix This PR fixes a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants